//
//  CHNouploadCell.m
//  CarFile
//
//  Created by 陈浩 on 2017/7/12.
//  Copyright © 2017年 陈浩. All rights reserved.
//

#import "CHNouploadCell.h"
@interface CHNouploadCell()
@property (nonatomic ,strong) UILabel *titleLabel;    // 企业名称
@property (nonatomic ,strong) UILabel *levelLabel;  //  业务类别
@property (nonatomic ,strong) UILabel *linkmanLabel;
@property (nonatomic ,strong) UILabel *telLabel;
@property (nonatomic ,strong) UIView *bgView;
@property (nonatomic ,strong) UIView *line;
@property (nonatomic ,strong) UILabel *resultLabel;
@property (nonatomic ,strong) UILabel *dayLabel;
@property (nonatomic ,strong) UILabel *nouploadLabel;
@property (nonatomic ,strong) UIImageView *arrowImgView;
@property (nonatomic ,strong) UIButton *arrowBtn;

@end
@implementation CHNouploadCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

+(instancetype)cellForTableView:(UITableView *)tableView{
    static NSString *ID = @"CHNouploadCell";
    CHNouploadCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if (!cell) {
        cell =[[CHNouploadCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID];
    }
    return cell;
    
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.backgroundColor = KRGB(239, 239, 249);
        [self buildUI];
    }
    return self;
    
}

-(void)buildUI{
    
    self.bgView = [[UIView alloc] init];
    self.bgView.backgroundColor = [UIColor whiteColor];
    [self addSubview:self.bgView];
    
    self.titleLabel = [[UILabel alloc] init];
    self.titleLabel.text = @"杭州启奥行汽车服务有限公司";
    self.titleLabel.font =  [UIFont fontWithName:@"Helvetica-Bold" size:16];
    [self.bgView addSubview:self.titleLabel];
    
    self.levelLabel = [[UILabel alloc] init];
    self.levelLabel.text = @"业务类别：二类维修经营业务";
    self.levelLabel.font = [UIFont systemFontOfSize:14];
    self.levelLabel.textColor = [UIColor colorWithHexString:@"999999" alpha:1.0f];
    [self.bgView addSubview:self.levelLabel];
    
    self.linkmanLabel = [[UILabel alloc] init];
    self.linkmanLabel.text = @"联系人：杜巨君";
    self.linkmanLabel.font = [UIFont systemFontOfSize:14];
    self.linkmanLabel.textColor = [UIColor colorWithHexString:@"999999" alpha:1.0f];
    [self.bgView addSubview:self.linkmanLabel];
    
    self.telLabel = [[UILabel alloc] init];
    self.telLabel.text = @"电话：18258845998";
    self.telLabel.font = [UIFont systemFontOfSize:14];
    self.telLabel.textColor = [UIColor colorWithHexString:@"999999" alpha:1.0f];
    [self.bgView addSubview:self.telLabel];
    
    self.line = [[UIView alloc] init];
    self.line.backgroundColor = [UIColor colorWithHexString:@"999999" alpha:0.1f];
    [self.bgView addSubview:self.line];
    
    self.nouploadLabel = [[UILabel alloc] init];
    self.nouploadLabel.font = [UIFont systemFontOfSize:14];
    self.nouploadLabel.text = @"累计未上传天数：";
//    self.nouploadLabel.textColor = [UIColor blackColor];
    [self.bgView addSubview:self.nouploadLabel];
    
    self.resultLabel = [[UILabel alloc] init];
    self.resultLabel.text = @"33";
    self.resultLabel.font = [UIFont systemFontOfSize:14];
    self.resultLabel.textColor = KRGB(251, 91, 111);
    [self.bgView addSubview:self.resultLabel];
    
    self.dayLabel = [[UILabel alloc] init];
    self.dayLabel.font = [UIFont systemFontOfSize:14];
    self.dayLabel.text = @"天";
    [self.bgView addSubview:self.dayLabel];
    
    self.arrowImgView = [[UIImageView alloc] init];
//    self.arrowImgView.backgroundColor = [UIColor orangeColor];
    self.arrowImgView.image = [UIImage imageNamed:@"right_arrow"];
    [self.bgView addSubview:self.arrowImgView];
    
    self.arrowBtn = [[UIButton alloc] init];
    [self.arrowBtn addTarget:self action:@selector(btnClick) forControlEvents:UIControlEventTouchUpInside];
    [self.bgView addSubview:self.arrowBtn];
    
  
}

-(void)btnClick{
    
    if (self.block) {
        self.block();
    }
}



-(void)setModel:(CHNouploadModel *)model{
    _model = model;
    self.titleLabel.text = model.name;
    self.linkmanLabel.text = [NSString stringWithFormat:@"联系人：%@",model.linkman];
    self.telLabel.text = [NSString stringWithFormat:@"电话：%@",model.busphone];
    self.resultLabel.text = model.noupdloadday;
    if ([model.levels isEqualToString:@"01"]) {
        self.levelLabel.text = @"业务类别：一类维修经营业务";
    }else if ([model.levels isEqualToString:@"02"]){
        self.levelLabel.text = @"业务类别：二类维修经营业务";
    }else{
        self.levelLabel.text = @"业务类别：三类维修经营业务";
    }
}

-(void)setInfo_model:(CHExceptionlistInfoModel *)info_model{
    _info_model = info_model;
    
    self.titleLabel.text = info_model.name;
    self.linkmanLabel.text = [NSString stringWithFormat:@"联系人：%@",info_model.linkman];
    self.telLabel.text = [NSString stringWithFormat:@"电话：%@",info_model.linktel];
    self.resultLabel.text = info_model.nouploads;
    if ([info_model.levels isEqualToString:@"01"]) {
        self.levelLabel.text = @"业务类别：一类维修经营业务";
    }else if ([info_model.levels isEqualToString:@"02"]){
        self.levelLabel.text = @"业务类别：二类维修经营业务";
    }else{
        self.levelLabel.text = @"业务类别：三类维修经营业务";
    }
    
}

-(void)layoutSubviews{
    [super layoutSubviews];
    
    self.bgView.frame = CGRectMake(0, 0, UIScreenW, 140);
    self.titleLabel.frame = CGRectMake(15, 10, UIScreenW - 30, 30);
    self.levelLabel.frame = CGRectMake(15, CGRectGetMaxY(self.titleLabel.frame), UIScreenW - 30, 30);
    self.linkmanLabel.frame = CGRectMake(15, CGRectGetMaxY(self.levelLabel.frame), UIScreenW /2, 30);
    self.telLabel.frame = CGRectMake(UIScreenW /2, CGRectGetMaxY(self.levelLabel.frame), UIScreenW /2, 30);
    self.line.frame = CGRectMake(0, CGRectGetMaxY(self.telLabel.frame), UIScreenW, 1);
    self.nouploadLabel.frame = CGRectMake(15, CGRectGetMaxY(self.line.frame) +5, 120, 30);
    self.resultLabel.frame = CGRectMake(CGRectGetMaxX(self.nouploadLabel.frame), CGRectGetMaxY(self.line.frame) +5, 30, 30);
    self.dayLabel.frame = CGRectMake(CGRectGetMaxX(self.resultLabel.frame), CGRectGetMaxY(self.line.frame) +5, 20, 30);
    
    self.arrowImgView.frame = CGRectMake(UIScreenW - 15 - 10, 115, 8, 12);
    self.arrowBtn.frame = CGRectMake(0, 100, UIScreenW, 40);
}

@end
